package com.andy;

import com.andy.util.ThreadLocalUrlUtil;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

@Activate(group = {CommonConstants.CONSUMER,CommonConstants.PROVIDER})
public class UrlFilter implements Filter {

    /**
     * Make sure call invoker.invoke() in your implementation.
     *
     * @param invoker
     * @param invocation
     */
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        ThreadLocalUrlUtil.setUrl(invoker.getUrl());
        return invoker.invoke(invocation);
    }
}
